
package checker;

import java.util.ArrayList;

public class DictionarySet {

	private ArrayList<Dictionary> dictionaries;

	/**
	 * @param d The first dictionary of the set
	 */
	public DictionarySet (Dictionary d) {
		dictionaries = new ArrayList<Dictionary>();
		dictionaries.add(d);
	}

	public DictionarySet () {
		this(null);
	}

	/**
	 * @param word The word to check if it's in the dictionary
	 * @return true if the word is in the dictionary
	 */
	public boolean contains(String word) {
		for(Dictionary d : dictionaries) {
			if (d.contains(word)) {
				return true;
			}
		}
		return false;
	}


	/**
	 * @param newDico The new dictionary to add to the set
	 */
	public void add(Dictionary newDico) {
		dictionaries.add(newDico);
	}


	/**
	 * @param i The index of the wanted dictionary
	 * @return The dictionary at the "i" index
	 */
	public Dictionary getDico(int i) {
		return dictionaries.get(i);
	}

	/**
	 * Save all the dictionaries on the disc
	 */
	public void allSave() {
		for(Dictionary d : dictionaries) {
			d.save();
		}
	}

	/**
	 * @return An arraylist containing the dictionaries
	 */
	public ArrayList<Dictionary> getDicos() {
		return dictionaries;
	}

	/**
	 * @return true if one of the dictionaries has been modified
	 */
	public boolean modified() {
		for(Dictionary d:dictionaries) {
			if (d.isModified()) {
				return true;
			}
		}
		return false;
	}
}
